;(function ($) {

    //农技
    $.ajax({
        url: getContextPath()+"/api/agt_agritech/page",
        data: {
            page: 1,
            limit: 6
        },
        dataType: "json",
        async: false,
        success: function (result) {
            let div = $("#services").find(".service-color-area");
            $.each(result.data, function (idx, obj) {
                let agtHtml = `<div class="col-md-4">
              <div class="service-box fadein">
                <div class="service-icon"><img height="160px" src="${obj.agritechCover}" alt=""/></div>
                <div class="service-content top-10">
                  <h3 class="bottom-10 service-title">${obj.agritechTitle}</h3>
                  <p>${obj.agritechAbstract}</p>
                </div>
                <div class="service-action top-20"><a href="/agritech/${obj.id}" class="button white stroke"><span>阅读全篇</span></a></div>
              </div>
            </div>`;
                div.append(agtHtml);
            });
        }
    });

    //百科
    $.ajax({
        url: getContextPath()+"/api/agt_species/page",
        data: {
            page: 1,
            limit: 15
        },
        dataType: "json",
        async: false,
        success: function (result) {
            let n = 1;
            let div = $("#team-members").find(".row");
            $.each(result.data, function (idx, obj) {
                if (n > 12) return true;
                if (obj.pid == 0) return true;
                let agtHtml = `<div style="margin-bottom: 10px;" class="col-lg-3 col-md-3 col-sm-3 col-xs-3 bottom-xs-30">
              <div class="team-member">
                <div class="team-member-image"><a href="/species/${obj.id}"><img class="" src="${obj.speciesCover}" alt=""
                                                                width="150" height="150"/></a></div>
                <div class="team-member-content fadein text-center">
                  <h4 class="bottom-0">${obj.speciesName}</h4>
                  <span class="desc">${obj.speciesAbstract.substring(0, 30)+"..."}</span>
                </div>
              </div>
            </div>`;
                div.append(agtHtml);
                n++;
            });
        }
    });

    //资讯
    $.ajax({
        url: getContextPath()+"/api/agt_article/page",
        data: {
            page: 1,
            limit: 6
        },
        dataType: "json",
        async: false,
        success: function (result) {
            // let div = $(".newsAgriDetail-news-con_list");
            let div1 = $(".newsAgriList");
            $.each(result.data, function (idx, obj) {
                /*let agtHtml = `<li>
                        <a href="/article/${obj.id}">${obj.articleTitle}</a>
                      </li>`;
                div.append(agtHtml);*/
                let divHtml = `<li class="used_agriListLi  jq22">
                  
                  <div class="border-left" style="height: 0px;"></div>
                  <div class="border-bottom" style="width: 0px;"></div>
                  <div class="border-top" style="width: 0px;"></div>
                  <div class="border-right" style="height: 0px;"></div>
                  
                  <div class="used_agriListCon">
                    <div class="used_agriListConLeft">
                      <img class="img-responsive" src="${obj.articleCover}" width="200" height="200">
                    </div>
                    <div class="used_agriListConRight">
                      <div class="used_agriListConRight_title">
                        <a href="/article/${obj.id}">
                          <h2>${obj.articleTitle}</h2>
                        </a>
                      </div>
                      <div class="used_agriListConRight_Con">
                        <a href="/article/${obj.id}">
                          <p>${obj.articleAbstract}</p>
                        </a>
                        <!--<div class="used_agriPublish">
                              <span class="publisher">
                                  <a href="javascript:;">文章所属模块</a>
                              </span>
                          <span class="publish_time">
                                  <p>2018-01-01</p>
                              </span>
                          <span class="publish_spread">
                                  <span>转发量:</span>
                                  <span>1111</span>
                              </span>
                          <span class="publish_comment">
                                  <span>评论量:</span>
                                  <span>1111</span>
                              </span>
                          <span class="publish_good">
                                  <span>点赞数:</span>
                                  <span>1111</span>
                              </span>
                        </div>-->
                      </div>
                    </div>
                  </div>
                </li>`;
                div1.append(divHtml);
            });
        }
    });

    $.ajax({
        url: getContextPath()+"/api/agt_article/page",
        data: {
            page: 1,
            limit: 6
        },
        dataType: "json",
        async: false,
        success: function (result) {
            let div = $(".newsAgriDetail-news-con_list");

            $.each(result.data, function (idx, obj) {
                let agtHtml = `<li>
                        <a href="/article/${obj.id}">${obj.articleTitle}</a>
                      </li>`;
                div.append(agtHtml);
            });
        }
    });

    /**
     * 获取项目根目录
     * @returns {string}
     */
    function getContextPath() {
        let pathName = document.location.pathname;
        let index = pathName.substr(1).indexOf("/");
        let result = pathName.substr(0, index + 1);
        // console.log(pathName,index,result);
        return result;
    }

})(window.jQuery);